package com.changgou.wbe.geteway.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpCookie;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Service;

@Service
public class AuthService {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public String getJtiFromCookie(ServerHttpRequest request) {

        HttpCookie cookie = request.getCookies ().getFirst ("uid");
        if ( cookie != null ) {
            String value = cookie.getValue ();
            return value;
        }
        return null;

    }

    public String getJtiFromRedis(String jti) {

        String jwt = stringRedisTemplate.boundValueOps (jti).get ();
        return jwt;

    }
}
